﻿Public Class RequestPromotion
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnPromote_Click(sender As Object, e As EventArgs) Handles btnPromote.Click
        Try

            If (drpPromotion.SelectedValue <> -1) Then
                If (drpPromotion.SelectedValue = 1) Then
                    If (User.IsInRole("Teacher")) Then
                        lblMessage.Text = "You are already a teacher"
                    Else
                        'send request

                        Dim sendPromotion As PromotionsRequestManagement = New PromotionsRequestManagement()
                        Dim userId As Int32 = New aspnet_UsersManagement().SelectUserIDByUsername(User.Identity.Name)
                        sendPromotion.InsertRequest(userId, drpPromotion.SelectedValue)
                        lblMessage.Text = "Your request as a teacher has been sent"
                    End If

                ElseIf (drpPromotion.SelectedValue = 2) Then
                    If (User.IsInRole("Admin")) Then
                        lblMessage.Text = "You are already an admin"
                    Else
                        'send request

                        Dim sendPromotion As PromotionsRequestManagement = New PromotionsRequestManagement()
                        Dim userId As Int32 = New aspnet_UsersManagement().SelectUserIDByUsername(User.Identity.Name)
                        sendPromotion.InsertRequest(userId, drpPromotion.SelectedValue)

                        lblMessage.Text = "Your request as an admin has been sent"
                    End If

                End If
            Else
                lblMessage.Text = "Select Promotion"
            End If

        Catch ex As Exception

        End Try
    End Sub
End Class